﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Web;

#region TwitterLikeSite
/// <summary>
/// TwitterLikeSite, base class for twitter like class
/// </summary>
class TwitterLikeSite : IMiniBlog
{
    public string url { get; set; }
    public string msgField { get; set; }
    public string username { get; set; }
    public string password { get; set; }

    protected  TwitterLikeSite()
    {
        this.msgField = "status";
    }

    #region post method
    public bool post(string message)
    {
        HttpHelper httpHelper = new HttpHelper();
        httpHelper.SetCredentials(this.username, this.password);

        string postData = msgField + "=" + HttpUtility.UrlEncode(message);
        string reposonse = httpHelper.GetHtml(url, postData, true);

        Debug.WriteLine(reposonse);

        // TODO, verify the response
        return true;
    }
    #endregion
}
#endregion

#region Twitter
class Twitter : TwitterLikeSite
{
    public Twitter(string username, string password)
    {
        this.username = username; this.password = password;
        this.url = "https://twitter.com/statuses/update.xml";
    }
}
#endregion

#region Fanfou
class Fanfou : TwitterLikeSite
{
    public Fanfou(string username, string password)
    {
        this.username = username; this.password = password;
        this.url = "http://api.fanfou.com/statuses/update.xml";
    }
}
#endregion

#region Jiwai
class Jiwai : TwitterLikeSite
{
    public Jiwai(string username, string password)
    {
        this.username = username; this.password = password;
        this.url = "http://api.jiwai.de/statuses/update.xml";
    }
}
#endregion

#region Digu
class Digu : TwitterLikeSite
{
    public Digu(string username, string password)
    {
        this.username = username; this.password = password;
        this.url = "http://api.digu.com/statuses/update.xml";
        this.msgField = "content";
    }
}
#endregion